package com.game.astd.web.entity;

import java.io.Serializable;

import org.json.JSONException;
import org.json.JSONObject;

public class JsonOpt<T> implements Serializable
{
	/**
	 * 没有权限访问
	 */
	public static final String CODE_NO_ACCESS = "403";

	private T obj = null;
	private boolean success = false;
	private String key = "";
	private String code = "";
	private String title = "";

	public JsonOpt(T _obj)
	{
		this.obj = _obj;
	}

	public String getKey()
	{
		return key;
	}

	public void setKey(String _key)
	{
		this.key = _key;
	}

	public String getCode()
	{
		return code;
	}

	public void setCode(String _code)
	{
		this.code = _code;
	}

	public String getTitle()
	{
		return title;
	}

	public void setTitle(String _title)
	{
		this.title = _title;
	}

	public T getObj()
	{
		return obj;
	}

	public void setObj(T _obj)
	{
		this.obj = _obj;
	}

	public boolean getSuccess()
	{
		return success;
	}

	public void setSuccess(boolean _successs)
	{
		this.success = _successs;
	}

	public String toString()
	{
		JSONObject joa = new JSONObject();
		try
		{
			joa.put("success", success);
			joa.put("data", obj);
			joa.put("key", key);
			joa.put("code", code);
			joa.put("title", title);
		} catch (JSONException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return joa.toString();
	}
}
